package com.leo.erp.enums;

public enum UserStateEnum {
	CHECK(0, "审核中"), OFFLINE(-1, "非法操作"), SUCCESS(1, "操作成功"), 
	USER_NOT_EXIST(2, "用户不存在"), USER_PASSWORD_ERROR(3,"用户密码错误"), LOGINNAME_EXIST(4, "登陆名已存在"), 
	USERNAME_EXIST(5, "登陆名已存在"), LOGINNAME_LIMIT(6, "此登陆名限制使用"), 
	USERNAME_LIMIT(7, "此用户名限制使用"), INNER_ERROR(-1001, "内部系统错误");
	private int state;
	private String stateInfo;
	
	private UserStateEnum(int state, String stateInfo) {
		this.state = state;
		this.stateInfo = stateInfo;
	}
	
	/**
	 * 依据传入的state返回相应的enum值
	 * 
	 * @param state
	 * @return
	 */
	public static UserStateEnum stateOf(int state) {
		for(UserStateEnum stateEnum : values()) {
			if(stateEnum.getState() == state) {
				return stateEnum;
			}
		}
		return null;
	}

	public int getState() {
		return state;
	}

	public String getStateInfo() {
		return stateInfo;
	}
}
